/**
 * \file kernel/network/network.h
 * \author Davide Gessa
 * \date 12-09-2009
 */
#ifndef NETWORK_NETWORK_H
#define NETWORK_NETWORK_H

#include <types.h>
#include <config.h>

#define NET_HARD_TYPE_NULL	0
#define NET_HARD_TYPE_LO	1
#define NET_HARD_TYPE_ETH	2


#ifdef IPV4
	#include <network/ipv4.h>	
#endif
#ifndef ADDR_LEN
	#define ADDR_LEN	4
#endif


/*
typedef struct
{
	char name[15];
} network_hardware_type_t;

network_hardware_type_t network_hardware_types[] = 
{ 
	{ "null\0" },
	{ "loopback\0" },
	{ "ethernet\0" }							
};
#define NETWORK_HARDWARE_TYPES_LEN (sizeof(network_hardware_types)/sizeof(network_hardware_type_t))
*/


/**
 * Interfaccia di rete
 */
typedef struct network_iface_p
{
	char name[32];					///< Nome interfaccia
	
	char addr[ADDR_LEN];			///< Indirizzo interfaccia
	char mask[ADDR_LEN];			///< Mask di rete
	char bcast[ADDR_LEN];			///< Indirizzo bcast della rete
	char gw[ADDR_LEN];				///< Indirizzo gw
	char mac[8];					///< Indirizzo mac
	
						
	uint8_t if_up;					///< L'interfaccia e' attiva?
	uint8_t if_gw;					///< C'e' un gateway?
	uint8_t if_mac;					///< C'e' un mac?
	
	uint8_t type;					///< Tipo di interfaccia
	
	uint32_t tx_bytes;				///< Byte trasmessi
	uint32_t rx_bytes;				///< Byte ricevuti
	
	struct network_iface_p *next;	///< Puntatore alla prossima iface
} network_iface_t;


network_iface_t *network_ifaces;	///< Interfaccie di rete


void network_init();
uint32_t network_iface_add(network_iface_t *);
uint32_t network_iface_up(char *);
uint32_t network_iface_down(char *);
uint32_t network_iface_getx(uint32_t, network_iface_t **);
uint32_t network_iface_get(char *, network_iface_t **);
char *network_addrtoa(char *, char *);

#endif
